package com.neusoft.elmboot.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.elmboot.po.VirtualWalletTransaction;

/**
 * @author chj
 * @date 2024年10月22日
 */
@Mapper
public interface VirtualWalletTransactionMapper {

	@Insert("insert into virtualwallettransaction(createTime,amount,fromWalletId,toWalletId,type,status) values(#{createTime},#{amount},#{fromWalletId},#{toWalletId},#{type},#{status})")
	@Options(useGeneratedKeys = true, keyProperty = "transactionId", keyColumn = "transactionId")
	int saveTransaction(VirtualWalletTransaction transaction);

	@Update("update virtualwallettransaction set status=#{status} where transactionId=#{transactionId}")
	int updateStatus(Long transactionId, String status);

	@Select("select * from virtualwallettransaction where fromWalletId=#{walletId} or toWalletId=#{walletId}")
	public List<VirtualWalletTransaction> listTransactions(Long walletId);

	// getnewId
	@Select("select * from virtualwallettransaction order by transactionId DESC LIMIT 1;")
	public Long getNewIds();

}
